﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KTool2.Core;

namespace KTool2.Impl
{
    class KanjiWordHistoryList : List<KanjiWord>
    {
        private int currentIndex = -1;

        //public int CurrentIndex
        //{
        //    get { return currentIndex; }
        //    set { currentIndex = value; }
        //}

        public void Add(KanjiWord kWord)
        {
            base.Add(kWord);

            if (this.Count > Common.Constant.MAX_OF_HISTORY_ELEMENT)
            {
                this[0].Release();
                this.RemoveAt(0);
                --this.currentIndex;
            }
        }

        public bool HasNext
        {
            get { return currentIndex < this.Count - 1; }
        }

        public bool HasPrevious
        {
            get { return currentIndex > 0; }
        }

        public KanjiWord Next
        {
            get { return this[++currentIndex]; }
        }

        public KanjiWord Previous
        {
            get { return this[--currentIndex]; }
        }

        public KanjiWord Current
        {
            get { return this[currentIndex]; }
        }

        public KanjiWord Head
        {
            get
            {
                currentIndex = this.Count - 1;
                return this[currentIndex];
            }
        }
    }
}
